package cn.sdhuijin.healthexam.activity;

import java.io.File;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;

/**
 * 高血压随访详细信息
 * 
 * 
 * @author houyuchun
 * 
 */
public class HypertensionVisitInfoActivity extends AbstractControlActivity
		implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_hypertension_visit_info);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		// 获取传递过来的sql语句
		String fileName = intent.getStringExtra("filename");
		initTextView();
		setTextViewValue(fileName);
		setButtonListener(this, R.id.btn_back);
	}

	@Override
	public void onClick(View v) {
		int clickId = (Integer) v.getId();
		switch (clickId) {
		case R.id.btn_back:
			finish();
			break;
		default:
			break;
		}
	}

	private void initTextView() {
		addTextView(R.id.txt_user_name, "姓名");
		addTextView(R.id.txt_identify_num, "身份证号");
		addTextView(R.id.txt_suifangfangshi, "随访方式_content");
		addTextView(R.id.txt_visit_date, "随访日期");
		addTextView(R.id.txt_zhengzhuang, "症状_content");
		addTextView(R.id.txt_qitazhengzhuang, "症状其他");
		addTextView(R.id.txt_gaoxueya, "高压");
		addTextView(R.id.txt_dixueya, "低压");
		addTextView(R.id.txt_tizhong, "体重");
		addTextView(R.id.txt_tizhizhishu, "体质指数");
		addTextView(R.id.txt_xinlv, "心率");
		addTextView(R.id.txt_qitatizheng, "体征其他");
		addTextView(R.id.txt_rixiyanliang, "日吸烟量");
		addTextView(R.id.txt_riyinjiuliang, "日饮酒量");
		addTextView(R.id.txt_meizhouydcs, "运动次数");
		addTextView(R.id.txt_meiciydsc, "运动时间");
		addTextView(R.id.txt_sheyanqingkuang, "摄盐情况_content");
		addTextView(R.id.txt_xinlitiaozheng, "心理调整_content");

		addTextView(R.id.txt_zunyixingwei, "遵医行为_content");
		addTextView(R.id.txt_fuzhujiancha, "辅助检查");
		addTextView(R.id.txt_fuyaoyicongxing, "服药依从性_content");
		addTextView(R.id.txt_yaowublfy, "药物不良反应_content");
		addTextView(R.id.txt_suifangfenlei, "此次随访分类_content");
		addTextView(R.id.txt_yaowu1, "药物名称一");
		addTextView(R.id.txt_yongfa1, "药物一次数");
		addTextView(R.id.txt_meicijiliang1, "药物一用量");
		addTextView(R.id.txt_yaowu1, "药物名称二");
		addTextView(R.id.txt_yongfa2, "药物二次数");
		addTextView(R.id.txt_meicijiliang2, "药物二用量");
		addTextView(R.id.txt_yaowu3, "药物名称三");
		addTextView(R.id.txt_yongfa3, "药物三次数");
		addTextView(R.id.txt_meicijiliang3, "药物三用量");
		addTextView(R.id.txt_qitayaowu, "其他药物名称");
		addTextView(R.id.txt_yongfa4, "其他药物次数");
		addTextView(R.id.txt_meicijiliang4, "其他药物用量");
		addTextView(R.id.txt_zhuanzhen, "转诊原因");
		addTextView(R.id.txt_zhuanzhenjigou, "转诊机构及科别");
		addTextView(R.id.txt_xiacisuifangrq, "下次随访日期");
		addTextView(R.id.txt_visit_doctor, "随访医生签名");
		addTextView(R.id.txt_suggestion, "指导意见");
	}

	/**
	 * 读取对应文件，设置各个控件值
	 * 
	 * @param fileName
	 *            文件名称
	 */
	private void setTextViewValue(String fileName) {
		try {
			File f = new File(Environment.getExternalStorageDirectory()
					.getPath() + "/health/" + fileName + ".txt");
			if (f.exists()) {
				controlManager.setPropertiesPath(f.getAbsolutePath());
				controlManager.toControl();
			} else {
				this.toastInformation(R.string.record_deleted);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
